package com.hex.ds.hdtp.core.inf.script.transfer.repository.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hex.ds.hdtp.core.inf.common.page.Page;
import com.hex.ds.hdtp.core.inf.common.page.converter.IPageAndMyBatisPlusPageConverter;
import com.hex.ds.hdtp.core.inf.script.transfer.mapper.IScriptVerifyLogMapper;
import com.hex.ds.hdtp.core.inf.script.transfer.po.ScriptVerifyLogPo;
import com.hex.ds.hdtp.core.inf.script.transfer.repository.IScriptVerifyLogRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptVerifyLogRepository implements IScriptVerifyLogRepository {

    private final IScriptVerifyLogMapper scriptTestLogMapper;

    private final IPageAndMyBatisPlusPageConverter pageConverter;

    @Override
    public Page<ScriptVerifyLogPo> queryListByPage(ScriptVerifyLogPo scriptVerifyLogPo, Page page) {
        final IPage tmpPageResult = scriptTestLogMapper.queryListByPage(
                pageConverter.toMyBatisPlusPage(page)
                , scriptVerifyLogPo
        );
        final List list = tmpPageResult.getRecords();
        final Page pageResult = pageConverter.toPage(tmpPageResult);
        return pageResult.setData(list);
    }

    @Override
    public Integer add(ScriptVerifyLogPo scriptVerifyLogPo) {
        return scriptTestLogMapper.insert(scriptVerifyLogPo);
    }

}

